package com.kgc.chapter01.vars

object Test_Four {
  def main(args: Array[String]): Unit = {
    println(filter(List(1, 9, 2, 8, 4, 7, 3), 5))
  }

  def filter(xs: List[Int], threshold: Int) = {
    def process(ys: List[Int]): List[Int] =
      if (ys.isEmpty)
        ys
      else if (ys.head < threshold)
        ys.head :: process(ys.tail)
      else
        process(ys.tail)
    process(xs)
  }

}
